package org.jing.ext.media.m3u8;

import org.jing.core.lang.ExceptionHandler;
import org.jing.core.lang.data.BaseSerializableDto;

import java.util.List;

/**
 * Description: <br>
 *
 * @author bksmate <br>
 * @since 2024-12-24 <br>
 */
public abstract class BaseM3U8Tag extends BaseSerializableDto {
    public void setParameter(String value) {}

    public void setExtParameters(List<String> parameters) {}

    protected abstract String outputValue();

    public final String output() {
        M3U8TagTypeInfo info = this.getClass().getAnnotation(M3U8TagTypeInfo.class);
        ExceptionHandler.publishIfMatch(null == info, "annotation required");
        String value = outputValue();
        if (null == value) {
            return "#" + info.value().getTagName();
        }
        else {
            return "#" + info.value().getTagName() + ":" + value;
        }
    }
}
